<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;
//后台订单 控制器
class OrdersController extends CommonController{
	private $ordersmodel;
	private $orderslistsmodel;
	public function __init(){
		parent::__init();
		$this->ordersmodel = new \Admin\Model\Orders;
		$this->orderslistsmodel = new \Admin\Model\Orderslists;
	}
	public function index(){
		$ordersData = $this->ordersmodel->get();
//		sp($ordersData);
//		分配
		View::with('ordersData',$ordersData);
		View::make();
	}
//	订单列表
	public function orderslists(){
//		1、提交物流信息修改
		if(IS_POST){
			if(!$this->ordersmodel->store()) View::error($this->ordersmodel->getError());
			View::success('物流信息修改成功');
		}
		$oid = Q('get.oid',0,'intval');
		$orderlistsData = $this->orderslistsmodel->where("order_oid={$oid}")->get();
//		sp($orderlistsData);
//		分配
		View::with('orderlistsData',$orderlistsData);
		View::make();
	}
//	删除订单
	public function delorders(){
		$oid = Q('get.oid',0,'intval');
		$this->ordersmodel->delete($oid);
//		删除，该订单下面的订单列表
		$olids = $this->orderslistsmodel->where("order_oid={$oid}")->lists("olid");
		foreach($olids as $v){
			$this->orderslistsmodel->delete($v);
		}
		go(U('index'));
	}
//	删除订单列表
	public function delorderslists(){
		$olid = Q('get.olid',0,'intval');
		$this->orderslistsmodel->delete($olid);
		go(U('index'));
	}
}



 ?>